Robust Jitter-Free Remote Clock Offset Measuring Method

ABSTRACT

A clock offset between a client and a server is measured by: (a) the client sending a request to the server; (b) upon receiving the request in step (a), the server optionally sending a server acknowledgement to the client; (c) upon the client receiving the server acknowledgement in step (b) or directly, if no acknowledgement was used, each of the client and the server proceeding to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (d) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges. The preferred apparent forwards and backwards delays are then selected based on the minimum values (for each direction) determined in (d) above. The clock offset between client and server is then determined based on the preferred apparent forwards and backwards delays.

TECHNICAL FIELD

The present invention generally concerns methods and apparatus for measuring a remote clock offset with very low jitter.

BACKGROUND

It is widely held that software-only solutions to clock synchronization suffer from inevitable “system noise” (process dispatching, interrupt handling etc.) that limit accuracy to 10 microseconds or worse. When microsecond-level synchronization is needed, hardware solutions are employed, e.g., network adapters with IEEE 1588 (Precise Time Protocol) support at both ends of the communications link.

As depicted in FIG. 1A, the typical software timestamp exchange has client node A send a timestamp T1 to server node B, which receives it at time T2. Server node B then sends a reply at time T3, and client node A receives it at time T4. T1 and T4 are measured using client node A's clock; T2 and T3 are measured on server node B's clock. From this information the offset between the clocks of client A and server B can be determined—but software as well as hardware delays contribute to high jitter. IEEE 1588 takes the timestamps at the hardware level, and provides an interface to collect those timestamps.

SUMMARY OF THE INVENTION

The present invention is directed to a method of robust jitter-free remote clock offset measuring.

In a first aspect of the invention, a clock offset between a client and a server is measured by:

(a) the client sending a request to the server; (b) upon receiving the request in step (a), the server optionally sending a server acknowledgement to the client; (c) upon the client receiving the server acknowledgement in step (b) or directly, if no acknowledgement was used, each of the client and the server proceeding to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (d) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.

The preferred apparent forwards and backwards delays are then selected based on the minimum values (for each direction) determined in (d) above.

The clock offset between client and server is then determined based on the preferred apparent forwards and backwards delays.

The foregoing summary of the various embodiments of the present invention is exemplary and non-limiting. For example, one with ordinary skill in the art will understand that one or more aspects or steps from one embodiment can be combined with one or more aspects or steps from another embodiment to create a new embodiment within the scope of the present invention.

BRIEF DESCRIPTION OF THE DRAWINGS

The foregoing and other aspects of these teachings are made more evident in the following Detailed Description of the Invention, when read in conjunction with the attached Drawing Figures, wherein:

FIG. 1A depicts an existing timestamp exchange method known in the prior art;

FIG. 1B depicts the same four-timestamp protocol, but in the way that matches the logical sequence used in the present invention;

FIG. 1C depicts the timestamp exchange protocol actually used in the present invention;

FIG. 2 depicts a flow diagram 200 for the invention;

FIG. 3 depicts the protocol as seen from the point of view of the client and server sides running concurrently; and

FIG. 4 depicts overlapping pingpong exchanges, where the normal FIG. 3 pattern is disturbed by a left-over pingpong packet from an earlier incomplete exchange.

FIG. 5 depicts a hardware block diagram of the client 100 and the server 200. As shown, the client 100 includes a processor 101 arranged to access a memory 103, where the memory 103 includes a computer program 102. Likewise, the server 200 includes a processor 201 arranged to access a memory 203, where the memory 203 includes a computer program 202.

DETAILED DESCRIPTION OF THE INVENTION

Briefly, a clock offset between a client and a server is measured as follows:

(a) the client sends a request for a “pingpong exchanger” to the server (who is waiting for this request passively, i.e. not consuming resources).

(b) upon receiving the request of step (a), the server optionally sends an acknowledgement to the client (who is also waiting passively, if this step is used). Whether or not an acknowledgement is sent, the server enters an active wait loop for the client's first pingpong packet.

(c) upon the client receiving the acknowledgement of step (b), or immediately after step (a) if step (b) did not involve an acknowledgement, the client starts the pingpong exchange by sending the first pingpong packet to the server and then waiting actively for a reply. Both client and server perform an agreed-upon number of pingpong exchanges. Each pingpong packet includes at least the timestamp at which it was sent.

(d) The apparent forwards and backwards delays are computed for each timestamp exchange, forming a multiplicity of (n) apparent forwards and backwards delays.

The preferred apparent forwards and backwards delays are then selected based on the minimum values (for each direction) determined in (d) above.

The clock offset between client and server is then determined based on the preferred apparent forwards and backwards delays.

The server acknowledgement step (b) above is optional, because it offers a tradeoff between the client spending extra time waiting actively for the server's first pingpong reply, and the server spending extra time waiting actively for the client's first pingpong packet.

In contrast to existing techniques, the present invention avoids system noise and high jitter by using a novel protocol that leads both sides of a timestamp exchange to run physically concurrently, which makes it possible to exploit a stretch of time that happens to be free from system noise. As a result, the shortest round-trip time among several consecutive timestamp exchanges (each of which may take tens of microseconds over current communication fabrics such as 1 G Ethernet, InfiniBand, etc.), can determine the clock offset with very low fitter.

The present invention can also address the send-receive asymmetry in the timing exchanges (as opposed to link-delay asymmetry).

Referring now to FIG. 1C, there is depicted the timestamp exchange protocol actually used in the present invention.

Moreover, referring generally to FIG. 2, there is shown a flow diagram 200 for the present method.

The method 200 comprises the following steps:

After starting, step 201, the method goes to step 203.

In step 203, the client initiates the process by sending a request to the server. The process then goes to step 205 or else directly to step 207 if step 205 is not used.

In optional step 205, upon receiving the request sent in step 203, the server sends a server acknowledgement to the client. The process then goes to step 207.

In step 207, upon the client receiving the foregoing server acknowledgement from step 205 or else directly if step 205 is not used, each of the client and the server proceed to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges. (This is described as a “pingpong” timestamp exchange below.) The process then goes to step 209.

In step 209, the process determines a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges in step 207. The process then goes to step 211.

In step 211, the preferred apparent forwards and backwards delays are then selected based on the minimum values (for each direction) that are determined in step 209. The process then goes to step 213.

In step 213, the process then determines the client or server clock offset based on the preferred apparent forwards and backwards delays determined in step 211.

In step 915, the process ends.

Still referring to FIG. 2, in various embodiments the multiplicity (n) of timestamp exchanges varies from 4 to 10.

Also, as described below, in various embodiments the process 200 includes determining a plurality of client-to-server (or “forwards”) apparent delays based on the multiplicity (n) of timestamp exchanges in step 207.

Further, as described below, in various embodiments the process 200 includes determining the forwards transport delay based on the minimum forwards apparent delay of the plurality of forward apparent delays.

Also, as described below, in various embodiments the process 200 includes determining a plurality of server-to-client (or “backwards”) apparent delays based on the multiplicity (n) of timestamp exchanges in step 207.

Furthermore, as described below, in various embodiments the process 200 includes determining the backwards transport delay based on the minimum backwards apparent delay of the plurality of backwards apparent delays.

Also, as described below, in various embodiments the process 200 uses Remote Direct Memory Access to reduce system noise.

Further, in various embodiments the determining steps 209, 211 and 213 are performed by the client.

Also, in various embodiments, the determining steps 209, 211 and 213 are performed by the server.

Moreover, in various embodiments, any of the determining steps 209, 211 and 213 are performed by any of the client and the server.

Referring now generally to FIGS. 3-4, if a client wants to track the clock of a server, in accordance with the process 200 described above in connection with FIG. 2, the client repeatedly requests a timestamp exchange in order to measure the current clock offset, and from a history of such measurements and appropriate filtering techniques it can then steer its clock to match that of the server. This might be done a few times per second, so that if the local oscillator's frequency is stable to one or two ppm, offsets can be controlled at the microsecond level.

Referring now to FIG. 3 there is shown an embodiment of “pingpong” timestamp exchanges, in accordance with the present invention.

As shown in FIG. 3, the client initiates such an exchange by requesting some number of “pingpong” timestamp exchanges (typically half a dozen) from the server, and the server acknowledges this request. This request and its acknowledgement can be sent over a regular socket interface, as timing is not yet critical. Both server and client then enter a tight loop, with the client sending first and the server receiving first, transferring timestamps T1, T2, . . . , T2 n, with odd indices denoting timestamps taken on the client and even indices denoting server timestamps. Each triplet T(i), T(i+1), T(i+2) is a condensed version of the typical four-timestamp exchange where the middle two are fused together. The difference between successive odd timestamps expresses the round-trip time as seen from the client, and the difference between successive even timestamps expresses the round-trip time as seen from the server.

The point of the repeated exchanges is to make the software go through the same path multiple times, which prime caches and TLBs, and to offer a choice of triplets from which to extract the clock offset. Indeed, with Convex Hull filtering techniques the forwards and backwards delays (difference between adjacent timestamps, e.g., Teven−Todd (T2−T1) for the forwards delay, and Todd−Teven (T3−T2) for the backwards delay) can be advantageously collected separately, and any system noise would be filtered out.

In various embodiments, for example as depicted in FIGS. 3 and 4, in order to recover from possible lost or delayed packets, it is advantageous to include a second timestamp in each pingpong packet, namely the “sent” timestamp of the packet to which this one is a reply. (A dummy value of zero would be used in the first pingpong packet, since that one is not in reply to another pingpong packet.). These timestamp pairs are shown alongside the arrows denoting the pingpong packets in FIGS. 3 and 4, in the form (Ta, Tb) where Tb is the primary timestamp of when the packet was sent, and Ta is a copy of the Tb of the packet to which this is a reply. Note that in a pingpong exchange, every packet other than the first is a reply to another pingpong packet, whether sent by the client or by the server.

This additional timestamp makes it easy to match replies to the packets sent, so as to extract consistent apparent delays even in the presence of interference, as depicted in FIG. 4. FIG. 4 depicts overlapping pingpong exchanges, where the normal FIG. 3 pattern is disturbed by a left-over pingpong packet from an earlier incomplete exchange. (FIG. 3 shows the normal case, without interference.)

Note that other error recovery techniques may be used that avoid the need for this secondary timestamp, e.g. flushing the communication channel after any timeout error, so as to guarantee (by transmission protocol properties) that the packets will automatically be matched.

An essential component of the invention is the initial message from the client to server, this initial message being depicted as step 203 in FIG. 2, requesting that the server enter a ping-pong timestamp exchange, with the client entering the pingpong timestamp exchange either directly, or upon receipt from the server of an acknowledgement (depicted as optional step 205 in FIG. 2). Any particular embodiment either does or does not exercise the acknowledgement option, as this is a design tradeoff. The purpose of this step 203 and step 205 “handshake” is to get both client process and server process to run physically at the same time, on different machines.

This “doorbell” exchange is not as time-critical as the pingpong exchange, and might use a different transport mechanism (e.g. regular sockets instead of InfiniBand RDMA). The contents of the doorbell packet are also different—it may contain the number of pingpong packets that are to be exchanged, for example. For this reason the “doorbell” and its optional acknowledgement packet are depicted as thick arrows in FIGS. 3 and 4, to distinguish them from pingpong packets.

Moreover, the reason for this “doorbell” initial request is that timestamp exchanges do not run continuously (that would consume too much CPU resources for no additional benefit), but are initiated periodically, with a period that is typically much longer than normal dispatch intervals. As a result, the server is most likely sleeping when the request arrives. Indeed, the client would also have been sleeping until its alarm clock went off telling it to initiate another exchange. So both processes would have to wake up, and a lot of lookaside state (caches, pages, TLB entries) would be stale and have to be refreshed, which takes time—generally a quite variable amount of time. Even the first pingpong exchange is likely to continue to refresh lookaside information, but from then on both client and server will repeat the exact same software path and benefit from an up-to-date lookaside state.

Because the software path used in replying to the just-received packet is (after one respectively one-and-a-half repetitions) the same on the client side and on the server side, this technique also avoids skewing the offset determination by the asymmetry between sender and receiver encountered in traditional implementations.

In the case of Remote Direct Memory Access (RDMA), as available with InfiniBand for example, there is no need for system calls after the initial handshake, as each side can do spin-loop polling for the other side's update to show up in the direct-mapped communication buffer.

This cuts out the largest component of system noise completely.

RDMA can be exploited to cut out “system noise” almost completely (after filtering out unexpected interruptions). Most other mechanisms involve one or more system calls during a timestamp exchange, and even in the absence of unexpected interruptions the software path is sufficiently long, with sufficiently many imponderables (e.g., number of items on various kernel to-do lists), so as to increase variability and hence delay jitter.

It remains possible for unrelated interruptions to interfere (as this protocol typically runs at ordinary user level), but those would be automatically filtered out by the Convex Hull technique, which discards any delays that are larger than the locally-shortest delays. For the aforementioned Convex Hull Filtering technique see, for example, “Method and system for clock skew and offset estimation”, by Scott Carlson, Michel Hack and Li Zhang, filed Sep. 9, 2005 in the USPTO as U.S. patent application Ser. No. 11/223,876, assigned to IBM Corporation.

In summary, in accordance with the invention, there is described a method for avoiding system noise when obtaining measurement data for clock synchronization. Accordingly, the invention uses a protocol that leads both sides of a timestamp exchange to run physically concurrently, which makes it possible to exploit a stretch of time that happens to be free from system noise. Further, the protocol allows features such as RDMA to be used to cut out system noise even more effectively. Further, the protocol addresses the send-receive asymmetry in the timing exchanges. Also, the protocol can recover from possible lost or delayed packets.

Thus there is described the first aspect of the invention, namely, the method of measuring a clock offset between a client and a server by:

(a) the client sending a request to the server; (b) upon receiving the request in step (a), the server optionally sending a server acknowledgement to the client; (c) upon the client receiving the server acknowledgement in step (b) or directly, if no acknowledgement was used, each of the client and the server proceeding to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (d) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.

The preferred apparent forwards and backwards delays are then selected based on the minimum values (for each direction) determined in (d) above.

The clock offset between client and server is then determined based on the preferred apparent forwards and backwards delays.

There also is described a second aspect of the invention, namely, a client configured to measure a clock offset with a server by a method comprising:

(a) sending a request to the serve; (b) exchanging timestamps with the server a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (c) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.

There is also described a third aspect of the invention, namely, a server configured to measure a clock offset with a client by a method comprising:

(a) receiving a request from the client; (b) exchanging timestamps with the client a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (c) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.

Finally, there also is described a fourth aspect of the invention, namely, a client and server configured for measuring a clock offset between the client and the server, comprising means for the client sending a request to the server; means for each of the client and the server proceeding to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and means for determining a plurality of apparent forwards delays and apparent backwards delays based on the multiplicity (n) of timestamp exchanges.

In various embodiments the fourth aspect further includes means for selecting the preferred apparent forwards and backwards delays respectively based on the minimum values for each of the apparent forwards delays and apparent backwards delays.

In various embodiments the fourth aspect further includes means for determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.

Thus it is seen that the foregoing description has provided by way of exemplary and non-limiting examples a full and informative description of the best apparatus and methods presently contemplated by the inventors for robust jitter-free remote clock offset measuring method. One skilled in the art will appreciate that the various embodiments described herein can be practiced individually; in combination with one or more other embodiments described herein; or in combination with methods and apparatus differing from those described herein. Further, one skilled in the art will appreciate that the present invention can be practiced by other than the described embodiments; that these described embodiments are presented for the purposes of illustration and not of limitation; and that the present invention is therefore limited only by the claims which follow. 

1. A method for measuring a clock offset between a client and a server, comprising: (a) the client sending a request to the server; (b) the client concurrently exchanging with the server their respective timestamps a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (c) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.
 2. The method of claim 1 further comprising selecting preferred apparent ones of the forwards and backwards delays based on the minimum values for each of the forwards and backwards delays determined in (c) above.
 3. The method of claim 2 further comprising determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.
 4. The method of claim 1 further comprising using remote direct memory access to reduce system noise.
 5. The method of claim 1, executed by the client.
 6. The method of claim 5 further comprising, by the client, selecting the preferred apparent forwards and backwards delays based on the minimum values for each of the forwards and backwards delays determined in (c) above.
 7. The method of claim 6 further comprising, by the client, determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.
 8. The method of claim 1 as executed based on a computer program stored in the memory of the client.
 9. The method of claim 8 further comprising, by the server, selecting the preferred apparent forwards and backwards delays based on the minimum values for each of the forwards and backwards delays determined in (c) above.
 10. The method of claim 9 further comprising, by the server, determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.
 11. A client configured to measure a clock offset with a server by a processor running a program stored on a memory configured to: (a) send a request to the server; (b) exchange timestamps with the server a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (c) determine a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.
 12. The client of claim 11, the processor further configured to select preferred apparent forwards and backwards delays based on minimum values for each of the forwards and backwards delays determined in (c) above.
 13. The client of claim 12, the method further comprising determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.
 14. A server configured to measure a clock offset with a client by a method comprising: (a) receiving a request from the client; (b) exchanging timestamps with the client a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and (c) determining a plurality of apparent forwards and backwards delays based on the multiplicity (n) of timestamp exchanges.
 15. The server of claim 14, the method further comprising selecting the preferred apparent forwards and backwards delays based on the minimum values for each of the forwards and backwards directions determined in (c) above.
 16. The server of claim 15, the method further comprising determining a clock Offset between the client and the server based on the preferred apparent forwards and backwards delays.
 17. A client and server configured for measuring a clock offset between the client and the server, comprising: means for the client sending a request to the server; means for each of the client and the server proceeding to concurrently exchange their respective timestamps with each other a multiplicity (n) of times, thus forming a multiplicity (n) of timestamp exchanges; and means for determining a plurality of apparent forwards delays and apparent backwards delays based on the multiplicity (n) of timestamp exchanges.
 18. The client and server of claim 17 further comprising means for selecting the preferred apparent forwards and backwards delays respectively based on the minimum values for each of the apparent forwards delays and apparent backwards delays.
 19. The client and server of claim 18 further comprising means for determining a clock offset between the client and the server based on the preferred apparent forwards and backwards delays.
 20. The client and server of claim 19, the determining of the plurality of apparent forwards delays and apparent backwards being performed by the client.
 21. The client and server of claim 20, the selecting of the preferred apparent forwards and backwards delays being performed by the client.
 22. The client and server of claim 21, the determining of a clock offset between the client and the server being performed by the client.
 23. The client and server of claim 19, the determining of the plurality of apparent forwards delays and apparent backwards delays being performed by the server.
 24. The client and server of claim 23, the selecting of the preferred apparent forwards and backwards delays being performed by the server.
 25. The client and server of claim 24, the determining a clock offset between the client and the server being performed by the server. 